using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using CodeSpirit.Amis.Attributes.FormFields;
using CodeSpirit.ExamApi.Data.Models.Enums;

namespace CodeSpirit.ExamApi.Dtos.PracticeSetting;

/// <summary>
/// 创建练习设置DTO
/// </summary>
public class CreatePracticeSettingDto
{
    /// <summary>
    /// 名称
    /// </summary>
    [Required(ErrorMessage = "名称不能为空")]
    [MaxLength(100, ErrorMessage = "名称长度不能超过100个字符")]
    [DisplayName("名称")]
    public string Name { get; set; } = string.Empty;
    
    /// <summary>
    /// 描述
    /// </summary>
    [MaxLength(500, ErrorMessage = "描述长度不能超过500个字符")]
    [DisplayName("描述")]
    public string? Description { get; set; }
    
    /// <summary>
    /// 试卷ID
    /// </summary>
    [DisplayName("试卷")]
    [Required(ErrorMessage = "请选择试卷")]
    [AmisSelectField(
        Source = "${ROOT_API}/api/exam/ExamPapers/select-published",
        ValueField = "id",
        LabelField = "name",
        Multiple = false,
        JoinValues = false,
        ExtractValue = true,
        Searchable = true,
        Clearable = true,
        Placeholder = "请选择试卷"
    )]
    public long ExamPaperId { get; set; }

    /// <summary>
    /// 练习模式
    /// </summary>
    [Required(ErrorMessage = "练习模式不能为空")]
    [DisplayName("练习模式")]
    public PracticeMode PracticeMode { get; set; }
    
    /// <summary>
    /// 练习次数限制(0表示不限制)
    /// </summary>
    [Range(0, int.MaxValue, ErrorMessage = "练习次数限制不能为负数")]
    [DisplayName("练习次数限制")]
    public int MaxAttempts { get; set; } = 0;
    
    /// <summary>
    /// 时长限制(分钟, 0表示不限制)
    /// </summary>
    [Range(0, int.MaxValue, ErrorMessage = "时长限制不能为负数")]
    [DisplayName("时长限制(分钟)")]
    public int TimeLimit { get; set; } = 0;
    
    /// <summary>
    /// 是否显示答案解析
    /// </summary>
    [DisplayName("显示答案解析")]
    public bool? ShowAnalysis { get; set; } = false;
    
    /// <summary>
    /// 是否随机排序题目
    /// </summary>
    [DisplayName("随机排序题目")]
    public bool? RandomizeQuestions { get; set; } = false;
} 